getMostRecentBaseline returns null when module is copied (How to get the major number)

Hi!

I have a bunch of modules that have been copied. Due that fact they do not have any baselines, although the next major release is not 1.0 (or the minor would be 0.1) [see my Screenshot if you do not know what i mean]. 

I have created an User Interface to create a baseline and to ask for some additional information that is not existing in the standard baseline dialog. 

My problem now is, that i have to find out what is the next minor and what is the next major baseline to populate radio boxes like in the standard dialog.

 

In the past i did this this way:

 

    Baseline b = getMostRecentBaseline(m);
    
    if(null b)
    {
        comboBoxAuswahl[0]= "0.1";
        comboBoxAuswahl[1]= "1.0";
    }
    else
    {
        comboBoxAuswahl[0]= (major b) "." ((minor b)+1) "";
        comboBoxAuswahl[1]= ((major b)+1) ".0";
    }
    
    radioBoxDBE=radioBox (mainDialog, "Version", comboBoxAuswahl, -1);

 

The problem now is, that getMostRecentBaseline always return null.

Is there another way to populate the fields? 


Bjoern_Karpenstein - Mon Mar 27 04:33:14 EDT 2017

Re: getMostRecentBaseline returns null when module is copied (How to get the major number)
Mathias Mamsch - Mon Mar 27 04:54:07 EDT 2017

If you don't mind leaking some Baseline objects, did you try: 

Baseline b = suffix(""); 

print (major b) " " (minor b) "\n"

Regards, Mathias

Re: getMostRecentBaseline returns null when module is copied (How to get the major number)
Bjoern_Karpenstein - Mon Mar 27 05:09:38 EDT 2017

Mathias Mamsch - Mon Mar 27 04:54:07 EDT 2017

If you don't mind leaking some Baseline objects, did you try: 

Baseline b = suffix(""); 

print (major b) " " (minor b) "\n"

Regards, Mathias

Thank you that works for me :)

Re: getMostRecentBaseline returns null when module is copied (How to get the major number)
Mathias Mamsch - Mon Mar 27 05:44:02 EDT 2017

Bjoern_Karpenstein - Mon Mar 27 05:09:38 EDT 2017

Thank you that works for me :)

If you experience problems when creating a baseline use something like this: 

string versionString = version current
Regexp re = regexp2 "([0-9]+)\\.([0-9]+)"
if (!re versionString) error "WTF?"
int major = intOf realOf versionString[match 1];
int minor = intOf realOf versionString[match 2]; 
print major " " minor "\n"

Regards, Mathias